package net.steam.easyjoboa.web.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import net.steam.easyjoboa.biz.DepartmentBiz;
import net.steam.easyjoboa.entity.Department;

public class DepartmentAction {
	
	private List<Department> listDepartments;
	private DepartmentBiz departmentBiz;
	private Department department; 
	private String massage;
	
	/**
	 * 得到所有部门
	 * @return
	 */
	public String getAllDep(){
		listDepartments = departmentBiz.getAllDepartment();
		return "getAllDep";
	}
	
	
	/**
	 * 添加部门
	 * @return
	 */
	@Action(value = "addDepartment",results={
			@Result(name="AddOK",type="redirect",location="/findEmployeesByDepar"),
			@Result(name="input",location="/AddDepartment.jsp")
			})
	public String addDepartment(){
		listDepartments =departmentBiz.getDeparByName(department.getDepartmentName());
		if (listDepartments.size()==0) {
			departmentBiz.addDepartment(department);
			return "AddOK";
		}
		massage = "所建部门已存在";
		return "input";
	}
	
	
	
	
	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public List<Department> getListDepartments() {
		return listDepartments;
	}

	public void setListDepartments(List<Department> listDepartments) {
		this.listDepartments = listDepartments;
	}

	public void setDepartmentBiz(DepartmentBiz departmentBiz) {
		this.departmentBiz = departmentBiz;
	}
	
	public String getMassage() {
		return massage;
	}

	public void setMassage(String massage) {
		this.massage = massage;
	}
}
